<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>跳转</title>
<script>
  var url = "https://www.w3.org/";
  function jump1() {
    location = url;
  }
  function jump2() {
    location = url;
  }
</script>
</head>
<body>
  <!-- 在点击超级链接时调用javascript函数 -->
  <a href="javascript:jump1()" onclick="return confirm('是否跳转至W3C')">W3C</a>
  <input type="button" value="W3C" onclick="if (confirm('是否跳转至W3C')) jump2()">
</body>
</html>